package TG_48;

public class Solution {
	public int[][] rotate(int[][] matrix) {
		if (matrix.length == 0) {
			return null;
		}
		int rows = matrix.length;
		int cols = matrix[0].length;
		for (int i = 0; i < rows; i++) {
			for (int j = i; j < cols; j++) {

				int temp = matrix[i][j];
				matrix[i][j] = matrix[j][i];
				matrix[j][i] = temp;

			}
		}

		for (int i = 0; i < rows; i++) {
			for (int j = 0; j < cols/2; j++) {
				int temp = matrix[i][j];
				matrix[i][j] = matrix[i][cols-j-1];
				matrix[i][cols-j-1] = temp;
			}
		}
		return matrix;

	}
}
